All Questions
35 questions
2votes
3answers
553views
Recursive palindrome check
I'm trying to solve this which basically calls for a recursive palindrome check with some minor extra steps (Special characters and whitespace can be ignored). The test inputs' length can be 100000 ...
6votes
3answers
2kviews
Money change exam
I was asked to create a method that would: Return a Change object or null if there was no possible change The "machine" has unlimited bills of: 2, 5 and 10 The Change object must return the ...
5votes
1answer
261views
Drawing a Thue-Morse pattern recursively
This is web exercise 3.1.63. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a program that reads in a command line input N and plots the N-by-N Thue-...
5votes
2answers
493views
How to optimize Karatsuba algorithm (using arraylist and java)
I was using Karatsuba algorithm to multiply two polynomials and return the coefficients and I am using java, we are asked to use arraylists here, however, my code is too complicated and it takes much ...
2votes
1answer
557views
Speeding up a recursive Cantor pairing function
The Cantor Pairing function is a mathematical function which takes two integers and combines them into a single integer that is unique to that pair. This single integer can later be "unpaired" back ...
2votes
2answers
152views
"Smart" sudoku brute-forcer
After running my C-brute-forcer for two days on a 25x25 sudoku, I decided to re-write in Java so that it would solve it in an acceptable time frame. The idea: Make smart fields that contain all ...
1vote
1answer
439views
Rectangle packing in smallest possible area
I have written a Java Program to place a bunch of rectangles into the smallest possible rectangluar area(no overlapping and rotating). Here is a short summary: I calculate minArea and maxArea: ...
4votes
3answers
1kviews
Java Magic square program
Here is my improved version of my Magic square program from following this earlier version. I also added a few comments. Any help for improvements would be really appreciated. ...
3votes
1answer
661views
Speed up Magic square program
I have written a Java program to calculate magic squares with recursion and backtracking. A 3*3 Magic square is calculated in about 1 sec, but a 4*4 needs about 50 minutes on my laptop with Intel i5. ...
1vote
1answer
496views
Counting contiguous subarrays with a negative sum
I'm doing a coding challenge that asks to count the number of contiguous subarrays that have a negative sum: A subarray of an n-element array is an array composed from a contiguous block of the ...
1vote
4answers
2kviews
Improving Fibonacci recursion with BigIntegers
I've been tasked with making a fast Fibonacci recursive method that uses BigInteger to calculate REALLY big numbers. However, to calculate numbers past 30 it takes ...
2votes
2answers
3kviews
All possible groups of combinations of array
Let's assume I have a one-dimensional array of integers of size n. My problem is to generate all the combination of all possible groups of size 1 to n, such as each combination has exactly one ...
6votes
2answers
20kviews
Find all words in a dictionary that can be made with a string of characters (Recursion/Binary Search)
I'm working on an algorithm that could take in a string of 20 random characters, and display to the user every word in a dictionary that can be successfully made with those letters, regardless of ...
4votes
1answer
2kviews
Pizza ordering program recursion on the GUI
This program is a basic pizza ordering program with seven topping options, four size options, and five crust options. It pulls the options from a database and populates the GUI on start. I connected ...
3votes
2answers
342views
Java exhaustive solution
This is a take on Pebble Solitaire. The user inputs n number of games and after that inputs a strings of length 23 that contains a combinations of only 'o' (pebble) and '-' (empty space). If there are ...